<?php
namespace Client\Controller;
use Think\Controller;
use Org\Net\Http;
class ScenicController extends Controller {
    public function index(){
    	$scenic = D('Scenic');
    	$where['city'] = 66;
    	$list = $scenic->where($where)->select();
    	var_dump($list);
    }
    public function showlist(){
    	S('scenic_list',null);
    	$list = S('scenic_list');
    	$pageSize = 10;
    	$page = I('page');
    	if(isset($page)){
    		$start = $page*$pageSize;
    	}
    	if(isset($list)){
    		$scenic = D('Scenic');
    		$list = $scenic->cache('scenic_list')->select();
    	}
    	$res = array_slice($list,$start,$pageSize);
    	if(count($res)>0){
    		$json['result'] = 0;
    		$json['msg'] = "成功";
    		$json['scenic'] = $res;
    	}else{
    		$json['result'] = -1;
    		$json['msg'] = "暂无更多的景区推荐";
    	}
    	var_dump($json);
//     	$this->ajaxReturn($json);
    }
    //获取景区信息（门票需要改）
    public function getScenic(){
    	$id = I('id');
    	$where['id'] = $id;
    	$scenic = D('Scenic');
    	$result = $scenic->where($where)->find();
    	if($result){
	    	$tickets = split(',', $result['ticket_info']);
	    	unset($result['ticket_info']);
	    	$ticket_list = array();
	    	foreach($tickets as $value){
	    		if($value != ''){
		    		$v = split(":", $value);
		    		$ticket = array();
		    		$ticket['name'] = $v[0];
		    		$ticket['price'] = $v[1];
		    		$ticket_list[] = $ticket;
	    		}
	    	}
	    	$result['ticket'] = $ticket_list;
	    	$discuss = D('ScenicDiscussView');
	    	$discuss_list = $discuss->where(array('sid'=>$id))->limit(5)->select();
	    	$result['discuss'] = $discuss_list;
    		$json['result'] = 0;
    		$json['msg'] = "成功";
    		$json['scenic'] = $result;
    	}else{
    		$json['result'] = -1;
    		$json['msg'] = "找不到该景区";
    	}
    	$this->ajaxReturn($json);
    }
}